
#ifndef _SD71_DK_H__
#define _SD71_DK_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "rtl876x_pinmux.h"

#define CONFIG_DLPS_EN                   0

/* if use user define dlps enter/dlps exit callback function */
#define USE_USER_DEFINE_DLPS_EXIT_CB      1
#define USE_USER_DEFINE_DLPS_ENTER_CB     1

/* if use any peripherals below, #define it 1 */
#define USE_I2C0_DLPS        1
#define USE_I2C1_DLPS        1
#define USE_TIM_DLPS         1
#define USE_QDECODER_DLPS    0
#define USE_IR_DLPS          0
#define USE_RTC_DLPS         1
#define USE_UART_DLPS        1
#define USE_ADC_DLPS         1 
#define USE_SPI0_DLPS        1
#define USE_SPI1_DLPS        0
#define USE_SPI2W_DLPS       0
#define USE_KEYSCAN_DLPS     0
#define USE_DMIC_DLPS        0
#define USE_GPIO_DLPS        1
#define USE_PWM0_DLPS        0
#define USE_PWM1_DLPS        0
#define USE_PWM2_DLPS        1
#define USE_PWM3_DLPS        1

#define USE_GDMACHANNEL0_DLPS       0
#define USE_GDMACHANNEL1_DLPS       0
#define USE_GDMACHANNEL2_DLPS       0
#define USE_GDMACHANNEL3_DLPS       0
#define USE_GDMACHANNEL4_DLPS       0
#define USE_GDMACHANNEL5_DLPS       0
#define USE_GDMACHANNEL6_DLPS       0
#define USE_GDMA_DLPS               (USE_GDMACHANNEL0_DLPS | USE_GDMACHANNEL1_DLPS | USE_GDMACHANNEL2_DLPS\
                                     | USE_GDMACHANNEL3_DLPS | USE_GDMACHANNEL4_DLPS | USE_GDMACHANNEL5_DLPS\
                                     | USE_GDMACHANNEL6_DLPS)
                                     
/* do not modify USE_IO_DRIVER_DLPS macro */
#define USE_IO_DRIVER_DLPS   (USE_I2C0_DLPS | USE_I2C1_DLPS | USE_TIM_DLPS | USE_QDECODER_DLPS\
                              | USE_IR_DLPS | USE_RTC_DLPS | USE_UART_DLPS | USE_SPI0_DLPS\
                              | USE_SPI1_DLPS | USE_SPI2W_DLPS | USE_KEYSCAN_DLPS | USE_DMIC_DLPS\
                              | USE_GPIO_DLPS | USE_USER_DEFINE_DLPS_EXIT_CB\
                              | USE_RTC_DLPS | USE_PWM0_DLPS | USE_PWM1_DLPS | USE_PWM2_DLPS\
                              | USE_PWM3_DLPS | USE_USER_DEFINE_DLPS_ENTER_CB)

#define KEY0_PIN		            P2_1 
#define GPIO_KEY0_IRQn               GPIO17_IRQn
#define GPIO_KEY0_IRQ_HANDLER       GPIO17_Handler



#define LCD_RS_PIN          P3_6
#define LCD_RESET_PIN       H_1 


#define LCD_SPI_BUS         SPI0
#define LCD_SPI_Periph      APBPeriph_SPI0
#define LCD_SPI_PeriphClk   APBPeriph_SPI0_CLOCK
#define LCD_SPI_CLK_PIN     P4_0
#define LCD_SPI_MOSI_PIN    P4_2
#define LCD_SPI_CS_PIN      P4_3
#define LCD_SPI_CLK_PIN_MUX     SPI0_CLK_MASTER
#define LCD_SPI_MOSI_PIN_MUX    SPI0_MO_MASTER
#define LCD_SPI_CS_PIN_MUX      SPI0_SS_N_0_MASTER

#define LCD_DMA_CHANNEL_NUM         1
#define LCD_DMA_CHANNEL_INDEX       GDMA_Channel1
#define LCD_DMA_CHANNEL_IRQ         GDMA0_Channel1_IRQn
#define LCD_DMA_HANDSHAKE           GDMA_Handshake_SPI0_TX
#define LCD_DMA_IRQ_HANDLER         GDMA0_Channel1_Handler

#define LCD_BLK_PWM_PIN     P3_3
#define LCD_BLK_PWM_TIMER_NUM   TIM2
#define LCD_BLK_PWM_TIMER_PIN_PINMUX    timer_pwm2
#define LCD_BLK_PWM_PERIOD      10000 // 1K
#define LCD_BLK_PWM_CYCLE       (LCD_BLK_PWM_PERIOD / 100 )
#define LCD_BLK_PWM_DUTY_CYCLE  50 

#define MOTOR_PWM_PIN       H_2
#define MOTOR_PWM_TIMER_NUM       TIM3
#define MOTOR_PWM_TIMER_PIN_PINMUX    timer_pwm3

#define MOTOR_PWM_PERIOD          1000 // us 
#define MOTOR_PWM_DUTY_CYCLE      50

#define BATTERY_ADC_PIN     P2_2 
#define BATTERY_ADC_INDEX   2 

#define BATTERY_CHARGE_DETECT_PIN   P0_0
#define BATTERY_CHARGE_DETECT_IRQn  GPIO0_IRQn
#define BATTERY_CHARGE_DETECT_IRQ_HANDLER  GPIO0_Handler

//========================================================================
// I2C(shared with G-sensor/TP/HRS) 
#define COMMON_SCL_PIN              P2_7
#define COMMON_SDA_PIN              P2_6
#define COMMON_I2C_BUS              I2C1
#define COMMON_FUN_SCL              I2C1_CLK
#define COMMON_FUN_SDA              I2C1_DAT
#define COMMON_I2C_PERIPH           APBPeriph_I2C1
#define COMMON_I2C_PERIPH_CLK       APBPeriph_I2C1_CLOCK
//========================================================================

#define G_SENSOR_INT_PIN            P2_5

#define G_SENSOR_SDA_PIN            COMMON_SDA_PIN
#define G_SENSOR_SCL_PIN            COMMON_SCL_PIN
#define G_SENSOR_I2C_BUS            COMMON_I2C_BUS 
#define G_SENSOR_FUN_SCL            COMMON_FUN_SCL
#define G_SENSOR_FUN_SDA            COMMON_FUN_SDA
#define G_SENSOR_I2C_PERIPH         COMMON_I2C_PERIPH
#define G_SENSOR_I2C_PERIPH_CLK     COMMON_I2C_PERIPH_CLK

#define G_SENSOR_INT_IRQn           GPIO21_IRQn
#define G_SENSOR_INT_IQR_HANDLER    GPIO21_Handler


#define HR_SDA_PIN                  COMMON_SDA_PIN
#define HR_SCL_PIN                  COMMON_SCL_PIN
#define HR_I2C_BUS                  COMMON_I2C_BUS 
#define HR_FUNC_SCL                 COMMON_FUN_SCL
#define HR_FUNC_SDA                 COMMON_FUN_SDA 
#define HR_I2C_PERIPH               COMMON_I2C_PERIPH
#define HR_I2C_PERIPH_CLK           COMMON_I2C_PERIPH_CLK

//#define HR_IRQ_PIN                  P1_2
#define HR_IRQ_IRQn                 GPIO10_IRQn
#define HR_IRQ_IRQn_HANDLER         GPIO10_Handler


#define TP_I2C_BUS                 COMMON_I2C_BUS
#define TP_SDA_PIN                 COMMON_SDA_PIN
#define TP_SCL_PIN                 COMMON_SCL_PIN
#define TP_FUNC_SCL                COMMON_FUN_SCL
#define TP_FUNC_SDA                COMMON_FUN_SDA
#define TP_I2C_PERIPH               COMMON_I2C_PERIPH
#define TP_I2C_PERIPH_CLK           COMMON_I2C_PERIPH_CLK

#define TP_IRQ_PIN                  P2_4
#define TP_RST_PIN                  P2_3 
#define TP_IRQ_IRQn                 GPIO20_IRQn
#define TP_IRQ_IRQn_HANDLER         GPIO20_Handler

/* auto K RF support */
#define MP_TEST_MODE_SUPPORT_DATA_UART_TEST 1  
#define MP_TEST_MODE_SUPPORT_AUTO_K_RF 1
#define MP_TEST_UART_TX_PIN     P3_0
#define MP_TEST_UART_RX_PIN     P3_1


#ifdef __cplusplus
}
#endif

#endif  /* _BOARD_H_ */
